package com.first.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.first.common.pojo.Order;
import com.first.common.vo.Result;
import com.first.order.service.OrderService;
import com.first.order.vo.OrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: SecondProject
 * @description:
 * @author: 李榕轩
 * @create: 2023-05-26 16:15
 **/
@RestController
@RequestMapping("order/order")
@Api(tags = "订单接口类")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @PostMapping("/getAllOrder/{currentPage}/{pageSize}")
    @ApiOperation(value = "分页+条件查询")
    public Result list(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody OrderVo orderVo) {
        //System.out.println(userVo);
        Page<Order> orderPage = orderService.findByPage(currentPage, pageSize, orderVo);

        return Result.success(orderPage);

    }
    @PostMapping("/selectMoney")
    @ApiOperation("平台总收入")
    public Result money(){
        Double aDouble = orderService.selectMoney();
        return Result.success(aDouble);
    }
    @PostMapping("/getOrderStatus/{id}/{memberId}")
    @ApiOperation("根据课程id和会员id查询支付状态")
    public Result getOrderStatus(@PathVariable String id,
                                 @PathVariable String memberId){
        Order orderStatus = orderService.getOrderStatus(id,memberId);
        return Result.success(orderStatus);
    }
}
